home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / ident / patches / sendmail-5.65c+IDA-1.4.4.1-ident.patch < prev    next >
Text File  |  1992-08-20  |  7KB  |  255 lines

  1. *** conf.h.orig    Tue Mar 31 16:00:07 1992
  2. --- conf.h    Tue Mar 31 16:01:40 1992
  3. ***************
  4. *** 92,97 ****
  5. --- 92,98 ----
  6.   # define NAMED_BIND    1    /* use Berkeley Internet Domain Server */
  7.   /*# define TTYNAME    1    /* set macro y to basename of tty device */
  8.   /*# define NOTUNIX    1    /* Define if msgs lack a UNIX "From " line */
  9. + #define AUTHUSER    1       /* Define to support the 'ident' protocol */
  10.   
  11.   /*
  12.    * Enable non-standard SMTP mods for talking to the DEC mail11v3 program.
  13. *** sendmail.h.orig    Tue Jul 28 04:34:20 1992
  14. --- sendmail.h    Tue Jul 28 04:35:57 1992
  15. ***************
  16. *** 713,718 ****
  17. --- 713,719 ----
  18.   EXTERN char    *QueueDir;    /* location of queue directory */
  19.   EXTERN char    *FileName;    /* name to print on error messages */
  20.   EXTERN char    *SmtpPhase;    /* current phase in SMTP processing */
  21. + EXTERN char    *RealUser;     /* name of user we're talking to (RFC931) */
  22.   EXTERN char    *MyHostName;    /* name of this host for SMTP messages */
  23.   EXTERN char    *RealHostName;    /* name of host we are talking to */
  24.   EXTERN char    *DeclHostName;    /* declared name of host we are talking to */
  25. *** deliver.c.orig    Tue Mar 31 15:55:01 1992
  26. --- deliver.c    Tue Mar 31 15:55:26 1992
  27. ***************
  28. *** 225,230 ****
  29. --- 225,240 ----
  30.   
  31.       define('g', tfrombuf, e);        /* translated sender address */
  32.       define('h', host, e);            /* to host */
  33. +     
  34. + #ifdef AUTHUSER
  35. +     if (RealHostName)
  36. +       define('S', RealHostName, CurEnv);
  37. +     
  38. +     /* RFC 931 sender name---2/7/91 DJB */
  39. +     if (RealUser)
  40. +       define('F', RealUser, CurEnv);
  41. + #endif
  42.       Errors = 0;
  43.       pvp = pv;
  44.       *pvp++ = m->m_argv[0];
  45. *** envelope.c.orig    Tue Mar 31 15:55:01 1992
  46. --- envelope.c    Tue Mar 31 15:55:26 1992
  47. ***************
  48. *** 476,482 ****
  49. --- 476,497 ----
  50.   #ifdef LOG
  51.               if (LogLevel >= 1)
  52.                   if (realname == from && RealHostName != NULL)
  53. + #ifdef AUTHUSER
  54.                   syslog(LOG_NOTICE,
  55. +                    "from=%s unparseable, received from %s%s%s",
  56. +                    from, 
  57. +                    RealUser ? RealUser : "",
  58. +                    RealUser ? "@" : "",
  59. +                    RealHostName);
  60. +                 else
  61. +                 syslog(LOG_NOTICE,
  62. +                     "Unparseable username %s wants from=%s",
  63. +                        realname, 
  64. +                        RealUser ? RealUser : "",
  65. +                        RealUser ? "@" : "",
  66. +                        from);
  67. + #else /* !AUTHUSER */
  68. +                 syslog(LOG_NOTICE,
  69.                       "from=%s unparseable, received from %s",
  70.                       from, RealHostName);
  71.                   else
  72. ***************
  73. *** 483,488 ****
  74. --- 498,504 ----
  75.                   syslog(LOG_NOTICE,
  76.                       "Unparseable username %s wants from=%s",
  77.                       realname, from);
  78. + #endif /* !AUTHUSER */
  79.   #endif /* LOG */
  80.           }
  81.           from = newstr(realname);
  82. *** headers.c.orig    Tue Mar 31 15:55:01 1992
  83. --- headers.c    Tue Mar 31 15:55:26 1992
  84. ***************
  85. *** 477,486 ****
  86. --- 477,496 ----
  87.           else
  88.               (void)sprintf(hbuf, "%.90s (%s)", 
  89.                   RealHostName, inet_ntoa(RealHostAddr.sin_addr));
  90. + #ifdef AUTHUSER
  91.           syslog(LOG_INFO,
  92. +             "%s: from=%s, size=%ld, class=%d, received from %s%s%s\n",
  93. +             CurEnv->e_id, CurEnv->e_from.q_paddr, CurEnv->e_msgsize,
  94. +             CurEnv->e_class, 
  95. +                RealUser ? RealUser : "",
  96. +                RealUser ? "@" : "",
  97. +                name);
  98. + #else
  99. +         syslog(LOG_INFO,
  100.               "%s: from=%s, size=%ld, class=%d, received from %s",
  101.               CurEnv->e_id, CurEnv->e_from.q_paddr, CurEnv->e_msgsize,
  102.               CurEnv->e_class, name);
  103. + #endif /* !AUTHUSER */        
  104.       }
  105.   #endif /* LOG */
  106.   }
  107. *** main.c.orig    Tue Mar 31 15:55:01 1992
  108. --- main.c    Tue Mar 31 15:55:27 1992
  109. ***************
  110. *** 48,53 ****
  111. --- 48,59 ----
  112.   # define MAXHOSTNAMELEN    64
  113.   #endif /* !MAXHOSTNAMELEN */
  114.   
  115. + #ifdef AUTHUSER
  116. + #include <netdb.h>
  117. + #include <errno.h>
  118. + #include <pwd.h>
  119. + #endif
  120. +   
  121.   #ifdef lint
  122.   int    edata, end;
  123.   #endif /* lint */
  124. ***************
  125. *** 876,881 ****
  126. --- 882,988 ----
  127.   #endif /* DAEMON */
  128.       }
  129.       
  130. + #ifdef AUTHUSER    
  131. +     {
  132. +       extern int auth_fd2();
  133. +       extern char *auth_tcpuser3();
  134. +       
  135. +       unsigned long inlocal;
  136. +       unsigned long inremote;
  137. +       unsigned short local;
  138. +       unsigned short remote;
  139. +       char *user;
  140. +       
  141. +       /* RFC 931 support added 2/7/91 by DJB */
  142. +       /* We could just use auth_xline but we don't */
  143. +       /* know the supposed username yet. */
  144. +       
  145. +       if (InChannel == NULL)
  146. +         user = NULL;
  147. +       else if (auth_fd2(fileno(InChannel),
  148. +                 &inlocal, &inremote, 
  149. +                 &local, &remote) != -1)
  150. +       {
  151. +           /* 30 second timeout added by pen@lysator.liu.se */
  152. +         user = auth_tcpuser3(inlocal, inremote, local, remote, 30);
  153. +         if (!user)
  154. +           user = NULL;
  155. +       }
  156. +       else
  157. +       {
  158. +         if (errno != ENOTSOCK)
  159. +           user = NULL;
  160. +         else
  161. +         {
  162. +           struct passwd *pwd;
  163. +           pwd = getpwuid(getuid());
  164. +           if (!pwd)
  165. +         user = NULL;
  166. +           else
  167. +         user = pwd->pw_name;
  168. +         }
  169. +       }
  170. +       if (user)
  171. +         RealUser = newstr(user);
  172. +       else
  173. +         RealUser = NULL;
  174. +     }
  175. +     if (RealHostName == NULL)
  176. +     {
  177. +       int len = sizeof(RealHostAddr);
  178. +       struct hostent *hp, *gethostbyaddr();
  179. +       char buf[200];
  180. +       
  181. +       
  182. +       if (InChannel &&
  183. +           getpeername(fileno(InChannel), &RealHostAddr, &len) != -1 &&
  184. +           RealHostAddr.sin_family == AF_INET)
  185. +       {
  186. +         /* determine host name */
  187. +         hp = gethostbyaddr((char *) &RealHostAddr.sin_addr,
  188. +                    sizeof RealHostAddr.sin_addr, AF_INET);
  189. +         if (hp != NULL)
  190. +           (void) strcpy(buf, hp->h_name);
  191. +         else
  192. +         {
  193. +           extern char *inet_ntoa();
  194. +           
  195. +           /* produce a dotted quad */
  196. +           (void) sprintf(buf, "[%s]",
  197. +                  inet_ntoa(RealHostAddr.sin_addr));
  198. +         }
  199. +         
  200. +         RealHostName = newstr(buf);
  201. +       }
  202. +       else
  203. +         if (InChannel && errno == ENOTSOCK)
  204. +         {
  205. +           char hname[256];
  206. +           
  207. +           /* determine host name */
  208. +           if (gethostname(hname, sizeof(hname)-1) != -1)
  209. +           {
  210. +         hp = gethostbyname(hname);
  211. +         if (hp != NULL)
  212. +           (void) strcpy(buf, hp->h_name);
  213. +         else
  214. +         {
  215. +           extern char *inet_ntoa();
  216. +           
  217. +           /* produce a dotted quad */
  218. +           (void) sprintf(buf, "[%s]",
  219. +                  inet_ntoa(RealHostAddr.sin_addr));
  220. +         }
  221. +         
  222. +         RealHostName = newstr(buf);
  223. +           }
  224. +         }
  225. +     }
  226. + #endif /* AUTHUSER */
  227.   #ifdef SMTP
  228.       /*
  229.       **  If running SMTP protocol, start collecting and executing
  230. *** srvrsmtp.c.orig    Tue Mar 31 15:55:01 1992
  231. --- srvrsmtp.c    Tue Mar 31 15:55:27 1992
  232. ***************
  233. *** 272,277 ****
  234. --- 272,285 ----
  235.                   break;
  236.               define('s', sendinghost, CurEnv);
  237.               define('r', "SMTP", CurEnv);
  238. + #ifdef AUTHUSER
  239. +             /* I want the _real_ hostname too.. */
  240. +             if (RealHostName)
  241. +                 define('S', RealHostName, CurEnv);
  242. +             /* RFC 931 sender name---2/7/91 DJB */
  243. +             if (RealUser)
  244. +               define('F', RealUser, CurEnv);
  245. + #endif
  246.               initsys();
  247.               setproctitle("%s %s: %s", CurEnv->e_id,
  248.                   CurHostName, inp);
  249.